3

方法一:

适用于python2和python3

>>> from collections import Iterable
>>> isinstance("str", Iterable)
True

方法二:

适用于python3

s = "hello world"
hasattr(s, "__iter__")

garnetreds7
21 声望2 粉丝

量化学习者,使用python